<template>
	<scroll-view
		scroll-y="true"
		class="scroll-Y"
		@scrolltolower="lower"
		:enable-flex="true"
		style="width: 100%;height: 100vh;"
	>
		<!-- 容器 -->

		<view style="width: 100%; margin-top: 40rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;">
			<!-- 当前所在团队 -->
			<text style="width: 702rpx; font-size: 32rpx;color: #333333;" class="text-bold">当前所在团队</text>
			<!-- 团队item -->
			<view
				class="padding b"
				style="width: 702rpx; margin-top: 30rpx;
			border-radius: 20rpx;background-color: #FFFFFF;padding-top: 30rpx;padding-bottom: 30rpx;"
				@tap="click"
			>
				<view style="width: 654rpx; display: flex;justify-content: flex-start; flex-direction: column;">
					<text style="font-size: 28rpx;color: #333333;" class="margin-bottom-xs">总人数： {{ data.count }}</text>
					<text style="font-size: 26rpx;color: #333333;" class="margin-bottom-xs">已销售人数：{{ data.my_count }}人</text>
					<text style="font-size: 26rpx;color: #666666;" class="margin-bottom-xs" v-if='data.createtime' >加入团队时间：{{ data.createtime | ddd    }}</text>
					<text style="font-size: 26rpx;color: #666666;" class="margin-bottom-xs" v-else >加入团队时间：***</text>
				</view>
				<view class="cu-avatar-group" style="display: flex; flex-wrap: wrap;justify-content: flex-end">
					<view
						class="cu-avatar bg-gradual-blue round"
						v-for="(item, index) in data.data"
						:key="index"
						style="width: 80rpx; height: 80rpx;"
						:style="[{ backgroundImage: 'url('  + 'http://jiyou.qianjiwl.xyz' + item.avatar + ')' }]"
					></view>
				</view>
			</view>

			<block v-if="data11.length!==0">
				
				<!-- 我的销售团队 -->
				<text style="width: 702rpx; font-size: 32rpx;color: #333333;margin-top: 39rpx;" class="text-bold">我的销售团队</text>
				<!-- 团队item -->
				<view
					@click="click1(index)"
					class="margin-top"
					style="width: 702rpx; display: flex;flex-direction: column;align-items: center;justify-content: center;
				border-radius: 20rpx;background-color: #FFFFFF;"
					v-for="(item, index) in data11"
					:key="index"
				>
					<view
						class="padding b"
						style="width: 702rpx; 
					border-radius: 20rpx;background-color: #FFFFFF;"
					>
						<view style="width: 654rpx; display: flex;justify-content: flex-start; flex-direction: column;">
							<text style="font-size: 28rpx;color: #333333;" class="margin-bottom-xs">总人数： {{ item.count }}</text>
							<text style="font-size: 26rpx;color: #333333;" class="margin-bottom-xs">已销售人数：{{ item.my_count }}人</text>
							<text style="font-size: 26rpx;color: #666666;" class="margin-bottom-xs" v-if=" item.createtime">加入团队时间：{{ item.createtime | ddd }}</text>
							<text style="font-size: 26rpx;color: #666666;" class="margin-bottom-xs" v-else>加入团队时间：***</text>
						</view>
						<view class="cu-avatar-group ">
							<view
								class="cu-avatar bg-cyan round"
								v-for="(ii, index1) in item.data"
								:key="index1"
								style="width: 80rpx; height: 80rpx;"
								:style="[{ backgroundImage: 'url(' + 'http://jiyou.qianjiwl.xyz' + ii.avatar + ')' }]"
							></view>
						</view>
					</view>
				</view>
						
						
			</block>
		
		</view>
	</scroll-view>
</template>

<script>
export default {
	data() {
		return {
			data: [],
			data11: [],
		};
	},
	onLoad() {
		this.getbrowseList();
		this.my_sales_team();
	},
	methods: {
		lower() {
			console.log('到达底部了');
		},
		click (){
			
			if (this.data.data.length) {
				this.jump('/pages/user/xiangqing', )
				uni.setStorageSync('list' ,this.data.data)
			}else {
				uni.$showMsg('暂无所在团队人数')
			}
		},
		click1(index){

			if (this.data11[index].data.length) {
				this.jump('/pages/user/xiangqing', )
				uni.setStorageSync('list' ,this.data11[index].data)
			}else {
				uni.$showMsg('暂无我的销售团队人数')
			}
		},

		async getbrowseList() {
			const res = await this.$api('my_my_insert_team');
			this.data = res.data;
			console.log('res :>> ', res);
		},
		async my_sales_team() {
			const res = await this.$api('my_sales_team');
			this.data11 = res.data;
			console.log('data11 :>> ', this.data11);
		},
		// tiaozhuan(){
		// 	console.log("111: ",111);
		// 	this.jump('/pages/user/xiangqing' , this.data.data)
		// },
		jump(path, parmas) {
			this.$Router.push({
				path: path,
				query: parmas
			});
			
		},
		ddd(msg){
				
				//讲字符串转为Date格式
				var msg1 = msg*1000
				
				var mt = new Date(msg1);
				//获取年份
				var year = mt.getFullYear();
				//从0开始，获取月份
				var month = (mt.getMonth() + 1).toString().padStart(2, '0');
				//获取天数
				var day = mt
					.getDay()
					.toString()
					.padStart(2, '0');
				/* if (con === 'yyyy/mm/dd'){
			                return year + "/" + month + "/" + day;
			            }*/
				//获取小时
				var hh = mt
					.getHours()
					.toString()
					.padStart(2, '0');
				//获取分钟
				var mm = mt
					.getMinutes()
					.toString()
					.padStart(2, '0');
				//获取秒
				var ss = mt
					.getSeconds()
					.toString()
					.padStart(2, '0');
				
				return year + '-' + month + '-' + day 
				//+ hh + ':' + mm + ':' + ss;
			
			
			
		}
			
	},
	filters: {
		ddd(msg){
			//讲字符串转为Date格式
			var msg1 = msg*1000
			
			var mt = new Date(msg1);
			//获取年份
			var year = mt.getFullYear();
			//从0开始，获取月份
			var month = (mt.getMonth() + 1).toString().padStart(2, '0');
			//获取天数
			var day = mt
				.getDay()
				.toString()
				.padStart(2, '0');
			/* if (con === 'yyyy/mm/dd'){
			            return year + "/" + month + "/" + day;
			        }*/
			//获取小时
			var hh = mt
				.getHours()
				.toString()
				.padStart(2, '0');
			//获取分钟
			var mm = mt
				.getMinutes()
				.toString()
				.padStart(2, '0');
			//获取秒
			var ss = mt
				.getSeconds()
				.toString()
				.padStart(2, '0');
			
			return year + '-' + month + '-' + day 
			//+ hh + ':' + mm + ':' + ss;
		}
	},
};
</script>

<style lang="scss" scoped>
page {
	background-color: #f9f9f9;
}
</style>
